package health.lm.com.home.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.home.R;
import health.lm.com.home.entity.HomeRecommendEntity;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.shop.adapter
 * Date：2019/8/15 16:55
 * Introduce：首页 上部商会推荐
 */
public class HomeFragmentRecommendAdapter extends BaseQuickAdapter<HomeRecommendEntity, BaseViewHolder> {
    public HomeFragmentRecommendAdapter(@Nullable List<HomeRecommendEntity> data) {
        super(R.layout.fragment_home_recommend_item, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(@NonNull BaseViewHolder helper, HomeRecommendEntity item) {
        ImageLoaderHelper.getInstance().load(mContext, item.getImage(), helper.getView(R.id.iv_image));
        helper.setText(R.id.tv_name, item.getName());
        for (int a = 0; a < item.getAvatar().size(); a++) {
            switch (a) {
                case 0:
                    ImageLoaderHelper.getInstance().load(mContext, item.getAvatar().get(a), helper.getView(R.id.iv_avatar_1));
                    break;
                case 1:
                    ImageLoaderHelper.getInstance().load(mContext, item.getAvatar().get(a), helper.getView(R.id.iv_avatar_2));
                    break;
                case 2:
                    ImageLoaderHelper.getInstance().load(mContext, item.getAvatar().get(a), helper.getView(R.id.iv_avatar_3));
                    break;
            }
        }
    }
}
